if(window.top!==window.self){window.top.location=window.location};
layui.use(['element'], function () {
    var $ = layui.jquery;
    $(document).on('click', '.captcha-img', function () {
        //验证码处理
        var src = this.src.split("?")[0];
        this.src = src + "?" + Math.random();
    });
    $(document).on('click', '.ajax-login', function (e) {
        e.preventDefault();
        var form = $(this).parents("form");
        var url = form.attr("action");
        var serializeArray = form.serializeArray();
        $.post(url, serializeArray, function (result) {
            if(result==='fail'){
                // $('.captcha-img').click();
                alert("用户名或密码错误")
            }else {
                console.log($('#username').val())
                if(window.top!==window.self){window.top.location=window.location};
                window.location.href = '/index'
                  // window.location.href = '/index?username='+ $('#username').val()
                // $.post('/index',{
                //     username: $('#username').text(),
                //     password: $('#password').text()
                // })
            }
            // $.fn.Messager(result);
        });
    });
    // $('.layui-layer-loading').hide();
});